commonProvince = {
  initPage:function() {
    this.data = {
      chartsdata: [],
      tableData: [],
      pageNum: 1,
      queryData: {
        page: 1,
        size: 10
      },
      chartsQueryData: {
        status: "in",
        areaCode: "",
        transType: "1,2,3",
        type: "1"
      },
      shengColum: [{field: 'name',title: '省份'},{field: 'carNum',title: '数量(单位：辆)',visible: true}],
      shiColum: [{field: 'name',title: '地市'},{field: 'carNum',title: '数量(单位：辆)',visible: true}],
      quColum: [{field: 'name',title: '区县'},{field: 'carNum',title: '数量(单位：辆)',visible: true}],
      columnData: [
        {
          field: 'no',
          title: '序号',
          align: 'center',
					formatter: function (value, row, index) {
            var pageSize = commonProvince.data.queryData.size;
            var pageNumber = commonProvince.data.queryData.page;
            return pageSize * (pageNumber - 1) + index + 1;
          }
        },
        {
          key: "vehicleNo",
          title: "车牌号码",
        },
        {
            key: "b",
            title: "车籍地",
        },
        {
            key: "transTypeCode",
            title: "行业类别",
        },
        {
            key: "exchangePlatform",
            title: "数据交换平台",
        },
        {
            key: "startTime",
            title: "跨域开始时间",
        },
        {
            key: "f",
            title: "跨域时长",
        },
        {
            key: "alarmSum",
            title: "跨域区间报警数",
        },
        {
            key: "endTime",
            title: "跨域结束时间",
        },
        {
            key: "owersName",
            title: "所属业户",
        },
        {
            key: "areaName",
            title: "所属地区",
        }
      ],
      XAData: [
        [{name:'西安'}, {name:'北京',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}],
        [{name:'西安'}, {name:'上海',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}],
        [{name:'西安'}, {name:'广州',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}],
        [{name:'西安'}, {name:'西宁',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}],
        [{name:'西安'}, {name:'银川',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}]
      ],
      XAData2: [
          [{name:'北京'}, {name:'西安',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}],
          [{name:'上海'}, {name:'西安',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}],
          [{name:'广州'}, {name:'西安',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}],
          [{name:'西宁'}, {name:'西安',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}],
          [{name:'银川'}, {name:'西安',child:[{name:"班线客运",value:50},{name:"旅游包车",value:40},{name:"危险品运输",value:20}]}]
        ],
      },
      // 地图表格初始化
      this.getShengDataOne();
      // setTimeout(() => {
      //   this.initChats();
      // },500);
      this.btnEven();
      this.selectedValue();
  },
  initTable(id,columns,data,total) { // 表格绘制初始化
    $("#" + id).bootstrapTable({
      method: 'get',
      cache: false,
      height: 420,
      pagination: true,
      pageSize: commonProvince.data.queryData.size,
      pageNumber:commonProvince.data.queryData.page,
      pageList: [10, 25, 50, 100],
      showColumns: true,
      striped: true,
      columns: columns,
      data :data,
      // sidePagination: 'server', // client or server
      totalRows: total,
      onPageChange: function (size, number) {
        commonProvince.data.queryData.size = size;
        commonProvince.data.queryData.page = number;
        // commonProvince.queryTableData();
      },
      formatNoMatches: function(){
          return '暂无数据';
      }
    });
  },
  initChartsTable(id,data,columns) {
    $("#" + id).bootstrapTable({
      method: 'get',
      cache: false,
      // height: 420,
      pagination: false,
      // pageSize: 10,
      // pageNumber:1,
      showColumns: false,
      // striped: true,
      columns: columns,
      data :data,
      onPageChange: function (size, number) {
        
      },
      formatNoMatches: function(){
        return '无符合条件的记录';
      }
    });
  },
  getShengDataOne() {
    $(".input_cont .combo-select .combo-input").val("陕西省");
    var queryData = {};
    queryData.parentId = "610000";
    queryData.transType = "1,2,3"
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610000";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      charts.map("charts1",commonProvince.data.XAData);
    })
  },
  getShengDataTwo() {
    $(".input_cont .combo-select .combo-input").val("陕西省");
    var queryData = {};
    queryData.parentId = "610000";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610000";
    this.data.chartsQueryData.status = "out";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      // console.log("接口数据 charts")
      // console.log(res.data)
      charts.map("charts1",commonProvince.data.XAData);
    })
  },
  getShiDataOne() {
    $(".input_cont .combo-select .combo-input").val("西安市");
    var queryData = {};
    queryData.parentId = "610100";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610100";
    this.data.chartsQueryData.status = "in";
    this.data.chartsQueryData.type = "2";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.map("charts1",commonProvince.data.XAData);
    })
  },
  getShiDataTwo() {
    $(".input_cont .combo-select .combo-input").val("西安市");
    var queryData = {};
    queryData.parentId = "610100";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610100";
    this.data.chartsQueryData.status = "in";
    this.data.chartsQueryData.type = "2";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.creatMapKuayu("charts1");
    })
  },
  getShiDataThree() {
    $(".input_cont .combo-select .combo-input").val("西安市");
    var queryData = {};
    queryData.parentId = "610100";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610100";
    this.data.chartsQueryData.status = "out";
    this.data.chartsQueryData.type = "2";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.creatMapKuayu("charts1");
    })
  },
  getShiDataFour() {
    $(".input_cont .combo-select .combo-input").val("西安市");
    var queryData = {};
    queryData.parentId = "610100";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610100";
    this.data.chartsQueryData.status = "out";
    this.data.chartsQueryData.type = "2";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.map("charts1",commonProvince.data.XAData);
    })
  },
  getQuDataOne() {
    $(".input_cont .combo-select .combo-input").val("雁塔区");
    var queryData = {};
    queryData.parentId = "610113";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610113";
    this.data.chartsQueryData.status = "in";
    this.data.chartsQueryData.type = "3";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.map("charts1",commonProvince.data.XAData);
    })
  },
  getQuDataTwo() {
    $(".input_cont .combo-select .combo-input").val("雁塔区");
    var queryData = {};
    queryData.parentId = "610113";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610113";
    this.data.chartsQueryData.status = "in";
    this.data.chartsQueryData.type = "3";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.map("charts1",commonProvince.data.XAData);
    })
  },
  getQuDataThree() {
    $(".input_cont .combo-select .combo-input").val("雁塔区");
    var queryData = {};
    queryData.parentId = "610113";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610113";
    this.data.chartsQueryData.status = "in";
    this.data.chartsQueryData.type = "3";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.creatQXMap("charts1");
    })
  },
  getQuDataFour() {
    $(".input_cont .combo-select .combo-input").val("雁塔区");
    var queryData = {};
    queryData.parentId = "610113";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610113";
    this.data.chartsQueryData.status = "out";
    this.data.chartsQueryData.type = "3";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.map("charts1",commonProvince.data.XAData2);
    })
  },
  getQuDataFive() {
    $(".input_cont .combo-select .combo-input").val("雁塔区");
    var queryData = {};
    queryData.parentId = "610113";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610113";
    this.data.chartsQueryData.status = "out";
    this.data.chartsQueryData.type = "3";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.creatMapKuayu("charts1");
    })
  },
  getQuDataSix() {
    $(".input_cont .combo-select .combo-input").val("雁塔区");
    var queryData = {};
    queryData.parentId = "610113";
    queryData.transType = "1,2,3";
    jrequest.get("/api/vehicle/thermogram",queryData).then(res => {
      res.data.forEach(item => {
        item.carNum = item.carNum + "辆";
      })
      $('#chartsDataList').bootstrapTable('destroy');
      commonProvince.initChartsTable("chartsDataList",res.data,commonProvince.data.shengColum);
    })
    this.data.chartsQueryData.areaCode = "610113";
    this.data.chartsQueryData.status = "out";
    this.data.chartsQueryData.type = "3";
    jrequest.get("/api/vehicles/getAreaMigrateBySX",this.data.chartsQueryData).then(res => {
      console.log("接口数据 charts")
      console.log(res.data)
      charts.map("charts1",commonProvince.data.XAData2);
    })
  },
  getCarSearchOut() { // 出域车辆查询
    var queryData = this.data.queryData;
    queryData.type = $(" .carsearchOut .combo-select .combo-dropdown li.option-selected").index();
    console.log(queryData.type)
    // jrequest.get("/api/vehicle/provinceOfOut",queryData).then(res => {
    //   console.log("接口数据 table")
    //   console.log(res.data)
      $(".table_list .table_out").show().siblings().hide();
      this.initTable("cnf_reportTableOut",commonProvince.data.columnData,commonProvince.data.tableData);
    // })
  },
  getCarSearchIn() { // 入域车辆查询
    var queryData = this.data.queryData;
    queryData.type = $(" .carsearchIn .combo-select .combo-dropdown li.option-selected").index();
    console.log(queryData.type)
    queryData.vehicleNo = $(".carsearchVehNo input").val();
    // jrequest.get("/api/vehicle/provinceOfOut",queryData).then(res => {
    //   console.log("接口数据 table")
    $(".table_list .table_in").show().siblings().hide();
    commonProvince.initTable("cnf_reportTableIn",commonProvince.data.columnData,commonProvince.data.tableData);
    // })
  },
  queryChartsTableData() {
    switch(this.data.pageNum) {
      case 1:
        this.getShengDataOne();
        break;
      case 2:
        this.getShengDataTwo();
        break;
      case 3:
        this.getShiDataOne();
        break;
      case 4:
        this.getShiDataTwo();
        break;
      case 5:
        this.getShiDataThree();
        break;
      case 6:
        this.getShiDataFour();
        break;
      case 7:
        this.getQuDataOne();
        break;
      case 8:
        this.getQuDataTwo();
        break;
      case 9:
        this.getQuDataThree();
        break;
      case 10:
        this.getQuDataFour();
        break;
      case 11:
        this.getQuDataFive();
        break;
      case 12:
        this.getQuDataSix();
        break;
    }
  },
  initChats() {
    for (var i = 0; i < 5; i++) {
      this.data.chartsdata.push({
          "name": "陕西省",
          "value": "3620辆"
      })
    };
    $(".chartsMap").css({"width":$(".chartsMap").width(),"height":$(".chartsMap").height()});
    charts.map("charts1",this.data.XAData); // 初始化地图渲染
  },
  selectedValue:function(){
		var self=this;
		var optionArr=["陕西省"];
		self.creatId("#selectSheng",optionArr);
		var optionArr1=["全部","班线客运","旅游包车","危险品运输"];
		self.creatId("#carsearch_typeOut",optionArr1);
		self.creatId("#carSearch_typeIn",optionArr1);
  },
	creatId:function(id,optionArr){
		$(id).html();
		var str="";
		$.each(optionArr,function (i) {
			str+="<option value='"+optionArr[i]+"'>"+optionArr[i]+"</option>"
		});
		$(id).html(str);
		$(id).comboSelect();
	},
  btnEven() {
    $(".charts_list").show(); //初始化
    $(".table_list").hide();
    // $("#selectShi").hide(); 
    // $("#selectQu").hide(); 
    $("#selectSheng").val("610000") // select赋值
    
    // 第一个
    $(".content_sheng").on("click",".carSearchName",function() {
      // 背景图切换
      $(this).addClass("activeName").siblings().removeClass("activeName");
      $(".content_shi div").removeClass("activeName");
      $(".content_qu div").removeClass("activeName");
      $(".content_carSearch div").removeClass("activeName");
      // 设置右侧显示隐藏
      let index=$(this).index();
      $(".charts_list").show();
      $(".table_list").hide();
      // $("#selectSheng .combo-select:first-child").show().siblings().hide();
      $("#selectSheng").show();
      // $("#selectShi").hide();
      // $("#selectQu").hide();
      if (index === 0) {
        commonProvince.data.pageNum = 1;
        $(".title_font span").html("外省车辆入省分析");
        commonProvince.getShengDataOne();
      } else if (index === 1) {
        commonProvince.data.pageNum = 2;
        $(".title_font span").html("本省车辆出省分析");
        charts.map("charts1",commonProvince.data.XAData2);
        commonProvince.getShengDataTwo();
      }
    })
    // 第二个
    $(".content_shi").on("click",".carSearchName",function() {
      // commonProvince.selectedValueSHI();
      $(".charts_list").show();
      $(".table_list").hide();
      // 背景图切换
      $(this).addClass("activeName").siblings().removeClass("activeName");
      $(".content_sheng div").removeClass("activeName");
      $(".content_qu div").removeClass("activeName");
      $(".content_carSearch div").removeClass("activeName");
      // $("#selectSheng .combo-select:nth-child(2)").show().siblings().hide();
      $("#selectSheng").hide();
      // $("#selectShi").show();
      // $("#selectQu").hide();
      // 设置右侧显示隐藏
      let index=$(this).index();
      switch(index) {
        case 0:
        commonProvince.data.pageNum = 3;
        $(".title_font span").html("外省车辆入市分析");
        commonProvince.getShiDataOne();
        break;
        case 1:
        commonProvince.data.pageNum = 4;
        $(".title_font span").html("本省外市车辆入市分析");
        commonProvince.getShiDataTwo();
        break;
        case 2:
        commonProvince.data.pageNum = 5;
        $(".title_font span").html("本省车辆出本省外市分析");
        commonProvince.getShiDataThree();
        break;
        case 3:
        commonProvince.data.pageNum = 6;
        $(".title_font span").html("本市车辆出外省分析");
        commonProvince.getShiDataFour();
        break;
      }
    })
    // 第三
    $(".content_qu").on("click",".carSearchName",function() {
      // commonProvince.selectedValueQU();
      $(".charts_list").show();
      $(".table_list").hide();
      // 背景图切换
      $(this).addClass("activeName").siblings().removeClass("activeName");
      $(".content_shi div").removeClass("activeName");
      $(".content_sheng div").removeClass("activeName");
      $(".content_carSearch div").removeClass("activeName");
      // $("#selectSheng .combo-select:last-child").show().siblings().hide();
      $("#selectSheng").hide();
      // $("#selectShi").hide();
      // $("#selectQu").show();
      // 设置右侧显示隐藏
      let index=$(this).index();
      switch(index) {
        case 0:
        commonProvince.data.pageNum = 7;
        $(".title_font span").html("外省车辆入县分析");
        commonProvince.getQuDataOne();
        break;
        case 1:
        commonProvince.data.pageNum = 8;
        $(".title_font span").html("外市车辆入县分析");
        commonProvince.getQuDataTwo();
        break;
        case 2:
        commonProvince.data.pageNum = 9;
        $(".title_font span").html("本市外县车辆入县分析");
        commonProvince.getQuDataThree();
        break;
        case 3:
        commonProvince.data.pageNum = 10;
        $(".title_font span").html("本市车辆出本市外县分析");
        commonProvince.getQuDataFour();
        break;
        case 4:
        commonProvince.data.pageNum = 11;
        $(".title_font span").html("本县车辆出外市分析");
        commonProvince.getQuDataFive();
        break;
        case 5:
        commonProvince.data.pageNum = 12;
        $(".title_font span").html("本县车辆出外省分析");
        commonProvince.getQuDataSix();
        break;
      }
    })
    // 第四
    $(".content_carSearch").on("click",".carSearchName",function() {
      // 背景图切换
      $(this).addClass("activeName").siblings().removeClass("activeName");
      $(".content_sheng div").removeClass("activeName");
      $(".content_shi div").removeClass("activeName");
      $(".content_qu div").removeClass("activeName");
      // 设置右侧显示隐藏
      let index=$(this).index();
      $(".charts_list").hide();
      $(".table_list").show();
      if (index === 0) {
        commonProvince.getCarSearchOut();
      } else {
        commonProvince.getCarSearchIn();
      }
    })

    $(".searchBtn").click(() => { // 地图界面查询
      commonProvince.queryChartsTableData();
    })
    $(".search_resetOut button:first-child").click(() => { // 出域 查询
      commonProvince.getCarSearchOut();
    })
    $(".search_resetOut button:last-child").click(() => { // 出域 重置
      $(".carsearchOut .combo-select .combo-dropdown li:first-child").addClass("option-selected").siblings().removeClass("option-selected"); // 抽检类型
      $(".carsearchOut .combo-select .combo-input").val("全部");
    })
    $(".search_resetIn button:first-child").click(() => { // 入域 查询
      commonProvince.getCarSearchIn();
    })
    $(".search_resetIn button:last-child").click(() => { // 入域 重置
      $(".carsearchIn .combo-select .combo-dropdown li:first-child").addClass("option-selected").siblings().removeClass("option-selected"); // 抽检类型
      $(".carsearchIn .combo-select .combo-input").val("全部");
    })



  }
}

$(function () {
  commonProvince.initPage();
})
